#include "loadedlib.hpp"

using namespace Utils;

LoadedLib* LoadedLib::Factory::New(const std::string& filepath)
{
  LoadedLib* newLib = 0;
  LIBTYPE    lib    = LoadLibrary(filepath.c_str());
  
  if (!(lib))
    std::cerr << "Can't load library " << filepath << " (" << ::GetLastError() << ")" << std::endl;
  else
    newLib = new LoadedLib(lib);
  return (newLib);
}

LoadedLib::LoadedLib(LIBTYPE lib) : lib(lib)
{
  error = 0;
}

LoadedLib::~LoadedLib(void)
{
  FreeLibrary(lib);
}

const char*     LoadedLib::GetLastError(void) const
{
  DWORD errorCode = ::GetLastError();
  
  return (error);
}